<?php
declare(strict_types=1);
namespace App\ZxAdmin\Sys\Stat;
use App\Controller;

// hook controller_sys_api_stat_use.php

/**
 * @title   接口统计
 * @auth    true
 * @login   true
 * @menu    true
 * @component vlist/index.vue
 * @icon el-icon-menu
 * @rank    4
 */
class SysApiStat extends Controller
{
    // hook controller_sys_api_stat_public_start.php

    // hook controller_sys_api_stat_public_end.php
    /**
     * @title   列表配置
     */
    public const Conf = [
        'pageSize' => 25,
        'remoteSort'=>0,
        'remoteFilter'=>0,
        'remoteSummary'=>0,
        'hidePagination'=>1,
        'hideRefresh'=>0,
        'hideSetting'=>0,
        'hideDo'=>0,
        'add'=>0,
        'start'=>0,
        'stop'=>0,
        'delete'=>0,
        'import'=>0,
        'export'=>0
    ];

    /**
     * @title  下发配置
     * @rank    0
     */
    public function action_Conf_PUT()
    {
        // hook controller_zx_admin_sys_server_conf_start.php
        $Columns = [
            [
                'label' => "日期",
                'prop' => "Ymd",
                'width' => "140px"
            ],
            [
                'label' => "时",
                'prop' => "H",
                'width' => "90px"
            ],
            [
                'label' => "接口",
                'prop' => "Node",
                'width' => "400px"
            ],
            [
                'label' => "Method",
                'prop' => "Method",
                'width' => "90px"
            ],
            [
                'label' => "请求数",
                'prop' => "Count",
                'width' => "100px"
            ],
             [
                'label' => "总耗时(Ms)",
                'prop' => "UseTime",
                'width' => "200px"
            ],
             [
                'label' => "均耗时(Ms)",
                'prop' => "Time",
                'valueGetter'=> '(node.data["UseTime"]/node.data["Count"]).toFixed(4)',
                'width' => "200px"
            ]
        ];

        // make conf SysDict ZxAdmin\Sys
        // hook controller_zx_admin_sys_server_conf_end.php
        $this->response('0000', ['Conf' => self::Conf, 'Filter' => [], 'Tools' => [], 'Columns' => $Columns, 'data' => []]);
    }

    /**
     * @title   获取页面数据
     * @rank    99
     */
    public function action_Index()
    {
        // hook controller_sys_api_stat_index_start.php
        $order=[];
        $cond = [];
        $data = $this->SysApiStat->select($cond,$order);
        // hook controller_sys_api_stat_index_end.php
        $this->response('0000', ['data' =>$data]);
    }

    // hook controller_sys_api_stat_end.php
}
?>